library('ggplot2')
library('plotly')
A graph of density of diamonds vs price using the data set ’diamonds`
dens <- with(diamonds, tapply(price, INDEX = cut, density))
dframe <- data.frame(
x = unlist(lapply(dens, "[[", "x")),
y = unlist(lapply(dens, "[[", "y")),
cut = rep(names(dens), each = length(dens[[1]]$x))
)
plot_ly(dframe, x = ~x, y = ~y, color = ~cut) %>% add_lines()
Volcano data visualization in 3D
plotly::plot_ly(z=volcano, type = "surface")